﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Layouts/List.Master" CodeBehind="DataDictionaryItemList.aspx.cs" Inherits="Bingosoft.WebApp.Modules.DataDictionary.DataDictionaryItemList" %>
<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
    <!-- title -->    
</asp:Content>

<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">   
    <!-- 搜索框 -->
	<div class="search" style="margin-top:2px;">
        <web:search ID="GridSearch" GridViewId="SmartGridView1" runat="server">            
            <SearchConditionTemplate>                                       
                <table cellpadding="0" cellspacing="0" width="95%">
			        <tr>
                        <th>
                            文本：
                        </th>
	                    <td>
		                    <asp:TextBox ID="Text" name="Text" runat="server" ></asp:TextBox>
	                    </td>                                        
                    </tr>
                </table>
            </SearchConditionTemplate>                      
        </web:search>        
    </div>

    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
				 数据字典项列表
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar"  style="height:30px;">
            <asp:LinkButton runat="server"
                OnClientClick="return openEditor(this, 'Insert');" OnClick="SearchGrid">
                <span>
                    <img alt="" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />新建
                </span>
            </asp:LinkButton>            
	    </div>
	    <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="Id" DataSourceID="SmartDataSource1" PageSize="10" onrowdatabound="SmartGridView1_RowDataBound">
                <Columns>  
                    <asp:BoundField DataField="Text" HeaderText="文本" SortExpression="Text" ItemStyle-HorizontalAlign="left" />
                    <asp:BoundField DataField="Code" HeaderText="编码" SortExpression="Code" ItemStyle-HorizontalAlign="left" />
                    <asp:BoundField DataField="Status_Text" HeaderText="状态"  ItemStyle-HorizontalAlign="center"/>
                    <asp:BoundField DataField="OrderId" HeaderText="序号" ItemStyle-HorizontalAlign="center" SortExpression="OrderId"/>
                    <asp:BoundField DataField="Description" HeaderText="描述" ItemStyle-HorizontalAlign="left" />
                                        
                    <asp:TemplateField HeaderText="操作">
                
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnEdit" runat="server" ToolTip="修改" _KeyId='<%#Eval("Id")%>'
                                            ImageUrl="~/images/com/dg_edit.gif" CausesValidation="False" OnClientClick="return openEditor(this, 'Edit');" OnClick="RefreshGrid">
                                        </asp:ImageButton>
                                    </td>
                                     <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="EnableImageButton" runat="server" ToolTip="启用"  _KeyId='<%#Eval("Id")%>' _Status='<%#Eval("STATUS")%>'
                                            ImageUrl="~/Images/ico_start.gif" CausesValidation="False" OnClick="Enable">
                                        </asp:ImageButton>
                                 
                                        <asp:ImageButton ID="DisableImageButton" runat="server" ToolTip="停用"  _KeyId='<%#Eval("Id")%>'
                                            ImageUrl="~/Images/ico_pause.gif" CausesValidation="False" OnClick="Disable">
                                        </asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnDelete" runat="server" ToolTip="删除" ImageUrl="~/images/com/dg_del.gif" _KeyId='<%#Eval("Id")%>'
                                          OnClientClick="return confirm('您确认要删除吗?')" OnClick="DeleteDictionaryItem">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="dataDictionary.list"
            SelectCommandAutoPageWrap="true" DefaultSortExpression="OrderId asc">       
                        
            </web:SmartSqlDataSource>
        </div>
	</div>

    <script type="text/javascript">
        var DictionaryId = "<%=Request.Params["DictionaryId"] %>";
        var DictionaryName = "<%=Request.Params["DictionaryName"] %>";

        function openEditor(_this, action) {
            var url = "DataDictionaryItemEdit.aspx";

            // FormViewMode : Insert/Edit/ReadOnly
            var params = { FormViewMode: action }
            if (action == "Insert") {
                params.title = "添加数据字典项";
                params.DictionaryId = DictionaryId;
                params.DictionaryName = DictionaryName;
            } else if (action == "Edit") {
                params.title = "编辑数据字典项";
                params.Id = _this.attributes["_KeyId"].value;
            }

            var returnValue = showCenterModalDialog(buildUrl(url, params), 500, 350);
            if (returnValue == "true") {
                window.parent.reloadTree();
                return true;
            }
            return false;
        }

    </script>
</asp:Content>
